<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <script type="text/javascript" src="<?php echo asset_url() . 'js/jquery-2.0.3.min.js'; ?>"></script>
        <title></title>
    </head>
    <body>
        <h3>New Comment</h3>
        <form id="comment" method="post">
            <label>Name: </label><input type="text" name="name" /><br />
            <label>Comment: </label><textarea name="comment_text" cols="25" rows="10"></textarea><br />
            <label>&nbsp;</label><input type="submit" value="Submit" />
        </form>

        <!-- here is the script that will do the ajax. It is triggered when the form is submitted -->
        <script>
            $(function() {
                $("#comment").submit(function() {
                    dataString = $("#comment").serialize();

                    $.ajax({
                        type: "POST",
                        url: "<?php echo base_url(); ?>index.php/comment/create",
                        data: dataString,
                        success: function(data) {
                            alert('Successful!);
                        }

                    });

                    return false;  //stop the actual form post !important!

                });
            });
        </script>
    </body>
</html>
